<!-- 金融机构待办 - 认证已办 -->
<template>
  <div>
    <Review ref="review" @ok="search"></Review>
    <ZgNewPage
      ref="page"
      :title="pageTitle"
      :showInlineBtn="false"
      :uniqueName="uniqueName"
      :pageOpt="pageOpt"
      :dataBtns="dataBtns"
      :headers="headers"
      :conditions="conditions"
      :adminWidth="90"
      :scrollX="1500"
      @search="onSearch"
      @filter="onFilter"
      @header="mergeHeader"
      @admin="toAdmin"
    >
      <template slot="columns">
        <a-table-column
          v-for="(h,i) in headers"
          :key="`column${i}`"
          :width="h.width===0 ? 'auto' : h.width"
          align="center"
          :title="h.label">
          <template slot-scope="record">
            <template v-if="h.code === 'C'">
              <span style="color:#1890ff">{{ record[h.code] }}</span>
            </template>
            <template v-else-if="h.code === 'G'">
              <span>{{ G[record[h.code]] }}</span>
            </template>
            <template v-else>{{ record[h.code] }}</template>
          </template>
        </a-table-column>
      </template>
      <template slot="thMode" slot-scope="scope">
        <a-row :gutter="10">
          <a-col :span="4" v-for="t in scope.list" :key="`thMode_${t.id}`">
            <a-card class="mb10">
              <div class="wfull h100 scroll">
                {{ t }}
              </div>
            </a-card>
          </a-col>
        </a-row>
      </template>
    </ZgNewPage>
  </div>
</template>
<script>
import Review from './Review'
const statusList = [
    { value: '1', label: '审核通过' },
    { value: '2', label: '待审核' },
    { value: '3', label: '驳回' }
]
export default {
    components: {
      Review
  },
  data () {
    return {
      pageTitle: '等级管理',
      uniqueName: 'test',
      G: {
        '1': '审核通过',
        '2': '待审核',
        '3': '驳回'
      },
      pageOpt: {
        showConditionBtn: true,
        showHeaderConfig: true,
        showAttachBtn: true,
        showDataCheck: true,
        showPageTitle: false
      },
      conditions: [
        { code: 'code', compType: '单行文本', label: '机构代码', defaultVal: '' },
        { code: 'name', compType: '单行文本', label: '机构名称', defaultVal: '' },
        { code: 'name', compType: '单行文本', label: '信用代码', defaultVal: '' },
        { code: 'date', compType: '日期区间', label: '服务截止', defaultVal: ['', ''] },
        { code: 'date', compType: '日期区间', label: '申请日期', defaultVal: ['', ''] },
        { code: 'status', compType: '下拉选择', label: '审核状态', defaultVal: '', extra: { 下拉选项: statusList } }
      ],
      headers: [
        { code: 'A', label: '机构代码', isShow: true, sort: 0 },
        { code: 'B', label: '总部名称/上级单位名称', isShow: true, sort: 0 },
        { code: 'C', label: '机构名称', isShow: true, sort: 0 },
        { code: 'D', label: '人行号', isShow: true, sort: 0 },
        { code: 'E', label: '信用代码', isShow: true, sort: 0 },
        { code: 'F', label: '金融机构类型', isShow: true, sort: 0 },
        { code: 'G', label: '审核状态', isShow: true, sort: 0 },
        { code: 'H', label: '注册时间', isShow: true, sort: 0 },
        { code: 'I', label: '申请时间', isShow: true, sort: 0 },
        { code: 'J', label: '审核时间', isShow: true, sort: 0 },
        { code: 'K', label: '审核结果', isShow: true, sort: 0 },
        { code: 'L', label: '审核备注', isShow: true, sort: 0 },
        { code: 'M', label: '审核人', isShow: true, sort: 0 }
      ],
      dataBtns: [
        { key: 1, name: '查看', type: 'link', isShow: () => { return true } }
      ]
    }
  },
  methods: {
    search () {
      this.$refs.page.search()
    },
    onSearch (param) {
      const diyHeaders = localStorage.getItem(this.currentUser.username + '_diyHeader_' + this.uniqueName)
      if (diyHeaders) {
        this.mergeHeader(JSON.parse(diyHeaders))
      }
      // 加载表头
      const list = [
        { key: '1', id: '1', A: '2021120', B: '光大银行', C: '光大银行股份有限公司太原分行', D: '022', E: '91141181699136277J', F: '银行', G: '2', H: '', I: '', J: '', K: '', L: '', M: '', isUse: true },
        { key: '2', id: '2', A: '2021121', B: '平安银行/平安银行支行', C: '平安银行股份有限公司太原分行', D: '322', E: '91141181699136277J', F: '银行', G: '2', H: '', I: '', J: '', K: '', L: '', M: '', isUse: true }
      ]
      this.$refs.page.endSearch({
        total: list.length,
        list: list
      })
    },
    onFilter (f, param) {
    },
    toAdmin (param) {
      if (param.key === 1) {
        this.$refs.review.open({}, 'details')
      }
    },
    mergeHeader (newHeaders) {
      if (!newHeaders) {
        return
      }
      this.headers = newHeaders.filter(t => {
        return t.isShow
      }).sort((a, b) => {
        return a.sort - b.sort
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
